//
//  AboutPopView.m
//  TQY
//
//  Created by 甘世清 on 2024/9/30.
//

#import "AboutPopView.h"

@implementation AboutPopView

- (void)SQ_UIViewForSelfView{
    self.backgroundColor = UIColor.whiteColor;
    self.layer.cornerRadius = 10;
    self.label = [[UILabel alloc]init];
    self.label.text = SQNSLocalString(@"活动描述");
    self.label.textColor = SQColor333333;
    self.label.font = FONT_MEDIUM(16);
    [self addSubview:self.label];
    [self.label mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.top.equalTo(self).offset(24);
    }];
    [self addSubview:self.fsTextView];
    [self.fsTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.width.mas_equalTo(SCREEN_WIDETH-40);
        make.height.mas_equalTo(140);
        make.top.equalTo(self).offset(60);
    }];
    [self addSubview:self.addButton];
    [self.addButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self);
            make.width.mas_equalTo(SCREEN_WIDETH-40);
            make.height.mas_equalTo(50);
            make.top.equalTo(self.fsTextView.mas_bottom).offset(40);
    }];
    [self addSubview:self.hideButton];
    [self.hideButton mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.right.equalTo(self);
            make.size.mas_equalTo(60);
    }];
    WS(weakSelf);
    [self.fsTextView addTextDidChangeHandler:^(FSTextView *textView) {
        if ([textView.formatText isNotEmpty]) {
            weakSelf.addButton.backgroundColor = SQColor3DA59D;
            weakSelf.addButton.textColor = SQColor(@"#FFFFFF");
        } else {
            weakSelf.addButton.backgroundColor = SQHexColor(@"#3DA59D", 0.4);
            weakSelf.addButton.textColor = SQColor(@"#000000");
        }
    }];
    [self.fsTextView becomeFirstResponder];
}
 
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self endEditing:YES];
}
-(FSTextView*)fsTextView{
    if (!_fsTextView) {
        _fsTextView = [FSTextView textView];
        _fsTextView.font = FONT_REGULAR(14);
        _fsTextView.textColor = UIColor.blackColor;
        _fsTextView.backgroundColor = UIColor.whiteColor;
        _fsTextView.layer.cornerRadius = 8;
        _fsTextView.layer.masksToBounds = YES;
        _fsTextView.layer.borderWidth = 1;
        _fsTextView.layer.borderColor = SQColor3DA59D.CGColor;
        _fsTextView.maxLength = 200;
    }
    return _fsTextView;
}
- (SQCustomButton *)addButton{
    if (!_addButton) {
        _addButton = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(0, 0) midmargin:0];
        _addButton.backgroundColor = SQColor3DA59D;
        _addButton.textColor = SQColor(@"#FFFFFF");
        _addButton.layer.cornerRadius = 25;
        _addButton.layer.masksToBounds = YES;
        _addButton.text = SQNSLocalString(@"确认");
        _addButton.font = FONT_MEDIUM(16);
    }
    return _addButton;
}
- (SQCustomButton *)hideButton{
    if (!_hideButton) {
        _hideButton = [[SQCustomButton alloc]initType:SQCustomButtonTopImageType imageSize:CGSizeMake(20, 20) midmargin:0];
        _hideButton.image = SQGetImage(@"guanbi");
    }
    return _hideButton;
}
@end
